﻿using Dapper;
using System.Data.SqlClient;
using yunbo.Model.BIP;
using yunbo.Model.SM;

namespace yunbo.Repositorys.BIPRepositorys
{
    public class BGRepository
    {
        public string data = "Data Source=121.37.93.71;Initial Catalog=FanXingMES;User ID=sa;Password=geili@2025;";
        public int PostBG(BG bg)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $@"insert into bg values('{bg.bg_code}','{bg.gx_code}','{bg.scgd_code}',{bg.bg_by},{bg.bg_scsl})";
                int ll = connection.Execute(sql);
                return ll;
            }
        }
        public List<BG> GetBG(string code)
        {
            using (SqlConnection connection = new SqlConnection(data))
            {
                string sql = $@"select *  from bg where scgd_code='{code}'";
                List<BG> bgs = connection.Query<BG>(sql).ToList();
                return bgs;
            }
        }
    }
}
